#include<bits/stdc++.h>
using namespace std;
long long n,l,r;
void In(){
	scanf("%lld%lld%lld",&n,&l,&r);
}
void Work(){
	printf("%lld\n",((r-(r%n))-1)>=l?n-1:r%n);
}
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	In();
	Work();
	return 0;
}
